﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MOReceive
{
    public class DBCustomer
    {
        private DBDataContext db;

        public DBCustomer()
        {
            db = new DBDataContext();
        }

        public bool ActiveCustomer(string cardNumber)
        {
            try
            {
                var query = from m in db.Customers
                            where m.CardNumber == cardNumber && m.IsActive == false
                            select m;

                var cus = query.FirstOrDefault();

                if (cus != null)
                {
                    cus.IsActive = true;
                    cus.Status = 2;

                    db.SubmitChanges();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}